package com.chainshop.utils;


import cn.hutool.core.util.RandomUtil;
import com.chainshop.common.core.domain.pojo.Restock;
import com.chainshop.common.core.domain.pojo.RestockProduct;
import com.chainshop.common.utils.DateUtils;

import java.util.List;


/**
 * @description:
 */
public class RestockUtils {
    public static Long getReplenishId(Restock restock) {
        String dateTime = DateUtils.dateTime(restock.getSubmitTime());
        dateTime = dateTime.replace("-", "") + restock.getStoreId() + RandomUtil.randomNumbers(4);
        return Long.valueOf(dateTime);
    }

    public static List<RestockProduct> modifyRestockProducts(List<RestockProduct> restockProducts, Long replenishId) {
        restockProducts.forEach(restockProduct -> {
            restockProduct.setReplenishId(replenishId);
            restockProduct.setProductId(restockProduct.getItemInformation().getId());
        });
        return restockProducts;
    }
}
